package com.test.observe;

import java.util.Observable;
import java.util.Observer;
import java.util.concurrent.TimeUnit;

public class EventHandler implements Observer {

	@Override
	public void update(Observable o, Object arg) {
		if (arg instanceof String) {
			System.out.printf("\r\nContent:%s,Observers:%d", arg, o.countObservers());
			System.out.println("\r\nSleeping 3 seconds...");
			try {
				TimeUnit.SECONDS.sleep(3);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			System.out.println("Update finished.");
		}
	}
}
